package com.foreknow.dao.impl;

import com.foreknow.bean.Admin;
import com.foreknow.dao.AdminDao;
import com.foreknow.mapping.EntityMapping;
import com.foreknow.mapping.MappingFactory;

import java.sql.SQLException;
import java.util.List;

public class AdminDaoImpl extends BaseDao implements AdminDao {

    @Override
    public Admin getAdminByNameByPass(String adminName, String password) throws SQLException {
        EntityMapping mapping = mappingFactory.mapping(MappingFactory.ADMIN_MAPPING);
        List<Object> list = jdbcTemplate.query("select * from admin where adminname=? and password=?",mapping,adminName,password);
        if(list.size()>0){
            return (Admin) list.get(0);
        }
        return null;
    }
}
